<template>
  <div class="container-y infoBody"
       :class="[{'container-y1':isMyTask || isWorkReport}]"
       style="z-index: 999">
    <bodyWrap :isShow="bodyShow">
      <div slot="body" class="infoWrap" v-if="bodyShow">
        <div class="desc-header">
          <h3>{{details.title}}</h3>
          <div class="dh-sec">
            <span><label for="">报送单位：</label>{{details.createUserInfo.orgName}}</span>
          </div>
          <div class="dh-sec">
            <span><label for="">报送人：</label>{{details.createUserInfo.linkdoodName}}</span>
          </div>
          <div class="dh-sec">
            <span><label for="">发生时间：</label>{{details.happenTime}}</span>
          </div>
          <div class="dh-sec">
            <span><label for="">联系方式：</label>{{details.createUserInfo.cellphone}}</span>
          </div>
          <div class="dh-sec">
            <span><label for="">传真：</label>{{details.fax}}</span>
          </div>
        </div>

        <template-items
          v-if="details != 99"
          v-for="(item,index) in temTitle"
          :key="index"
          :list="temList">
        </template-items>

        <div class="desc-body bt2" v-if="zjAdviceList.length || $store.state.userInfo.roleRank == 6">
          <h6>专家研判：</h6>
          <div class="db-content">
            <div v-for="item in zjAdviceList">
              <div class="zj1">{{item.userName}}&nbsp;&nbsp;{{item.judgedTime}}</div>
              <pre>研判要求：{{item.require}}</pre>
              <pre>研判意见：{{item.advice}}</pre>
            </div>
          </div>
        </div>

        <template v-if="zjDetail && zjDetail.isJudged == 0">
          <div class="desc-body bt bt2">
            <h6>研判意见：</h6>
            <div class="db-content">
              <textarea placeholder="点击输入文字" id="opinion"></textarea>
            </div>
          </div>
          <div class="btn-wrap">
            <div class="btn-b" @click="zjSubmit(0)">
              提交
            </div>
          </div>
        </template>
      </div>
    </bodyWrap>
  </div>
</template>

<script>
  import store from "../../store/store.js"
  import templateItems from "../commonComponents/templateItems.vue"
  export default {
    data() {
      return {
        details: 99,
        fileList: [],
        headerRightType: null,
        headerFlag: null,
        bodyShow: false,
        isMyTask: false,
        isWorkReport: false,
        zjDetail: false,
        isSubmitAgain: 0,
        zjAdviceList: [],
        temTitle: [1],
        temList: [],
      }
    },
    methods: {
      getDetail() {
        let self = this;
        let id = _methods.getUrlParam("id");
        this.id = id;
        let type = _methods.getUrlParam("type");
        let ajUrl;
        if (type == 1) {
          ajUrl = _methods.copyObj(_ajaxUrls.addInfoList);
        }
        else if (type == 90) {
          ajUrl = _ajaxUrls.judged;
          this.isMyTask = true;
        }
        else {
          ajUrl = _ajaxUrls.baseTable;
        }
        _ajax.noLoading(ajUrl.url + "/" + id,
          {},
          (ajData) => {
            let data = ajData.result;
            if (type == 90) {
              self.zjDetail = data;
              self.details = data.article;
              self.temList = _methods.temRead(data.article.extend);
              if (_data.userInfo.roleRank == 6) {
                this.zjAdvice();
              }
            }
            else {
              self.details = data;
              self.temList = _methods.temRead(data.extend);
            }
            if (type != 1) {
              _data.userInfo.isCenterInit(() => {
                this.zjAdvice();
              }, () => {
              });
            }
            self.bodyShow = true;
          }, ajUrl.type);


      },
      zjAdvice(id) {
        let data = {
          pageIndex: 1,
          messageId: id,
          pageSize: 100,
          userId: _data.userInfo.userId,
        };
        _ajax.noLoading(_ajaxUrls.infoJudgeAdvise.url, data,
          (ajData) => {
            let data = ajData.data.list;
            this.zjAdviceList = data;
          }, _ajaxUrls.infoJudgeAdvise.type);
      },
      zjAdvice() {
        if (this.zjDetail.articleID) {
          _ajax.noLoading(_ajaxUrls.judged.url,
            {
              size: 999,
              page: 1,
              articleID: this.zjDetail.articleID,
            },
            (ajData) => {
              this.zjAdviceList = ajData.result.records;
            }, "get");
        }
      },
      zjSubmit() {
        let data = {
          advice: _methods.getValue("opinion"),
        };

        _ajax.confirmWithLoading(_ajaxUrls.judged.url + "/" + this.id,
          data,
          () => {
            _methods.indexLIstRefresh();
            _alert.alert(() => {
              _vrvInit.isPushCloseWindow();
              _methods.goBack();
            }, "提交成功");
          },
          "PUT",
          '是否确认提交？');

      },
    },
    created() {
      _vrvInit.isPush().then(() => {
        this.headerRightType = store.state.headerRightType;
        this.headerFlag = store.state.showFlag;
        _methods.headerRightShow();
        this.type = _methods.getUrlParam(101);
        _methods.headerTitleChange(101);
        this.getDetail();
      });
    },
    components: {
      templateItems,
    },
    beforeDestroy() {
      _methods.headerRightShow(this.headerRightType);
      _methods.headerTitleChange(this.headerFlag, true);
    }
  }

</script>

<style>
  .container-y1 {
    top: 40px !important;
  }

  .db-content textarea {
    text-indent: 14px;
    border: none;
  }
</style>

